package org.zecontech.plantvszombie.item;

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.OutgoingChatMessage;
import net.minecraft.network.chat.PlayerChatMessage;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.Level;

public class KelongItem extends Item {

    public KelongItem(Properties properties) {
        super(properties);
    }

    @Override
    public InteractionResult use(Level level, Player player, InteractionHand interactionHand) {
        var server = player.getServer();
        if (server != null) {
            server.getPlayerList().getPlayers().forEach(player1 -> {
                player1.sendSystemMessage(Component.literal("陈科龙是大帅哥"));
                player1.sendSystemMessage(Component.literal("陈科龙长得非常帅"));
            });
            server.getPlayerList().getPlayers().forEach(player1 -> {
                player1.sendSystemMessage(Component.translatable("info.plant-vs-zombie.you_can_not_plant_it"));
            });
        }
        player.addEffect(new MobEffectInstance(MobEffects.SPEED, 10, 10));
        return super.use(level, player, interactionHand);
    }
}
